package cn.rengy.web.framework.sys.rolemenu.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.rengy.web.framework.sql.DbService;
/**
 * 菜单角色关系表
 *
 */
@Service
public class RoleMenuService {
	@Autowired
	private DbService dbService;
	private static Logger logger = LoggerFactory.getLogger(RoleMenuService.class);
	
	/**
	 * 保存角色菜单授权
	 * @param paramMap
	 */
	@Transactional
	public void update(Map<String,Object> paramMap){
		Object roleid=paramMap.get("roleid");
		Object menuids=paramMap.get("menuids");
		this.dbService.updateBeanParameter("delete_role_menu_rel_byrole", roleid);
		if(menuids!=null){
			List ids=(List)menuids;
			Map<String,Object> paramMap2=new HashMap<String,Object>();
			paramMap2.put("role_id", roleid);
			for(Object menuid:ids){
				paramMap2.put("menu_id", menuid);
				this.dbService.updateMapParameter("insert_role_menu_rel", paramMap2);
			}
		}
	}
}
